<%@include file="_header.jspf" %>
<%@page import="com.spartancoder.accommodation.models.University" %>
<%@page import="com.spartancoder.accommodation.beans.UniversityBean" %>
<%@page import="com.spartancoder.accommodation.models.College" %>
<%@page import="com.spartancoder.accommodation.beans.CollegeBean" %>
<%
UniversityBean ub = University.fetch(Integer.parseInt(request.getParameter("id")));
%>

<h2><%=ub.getName()%></h2>

<table>
    <thead>
    <tr>
        <th>ID</th>
        <th>Nume</th>
        <th>Adresa</th>
        <th>Stare</th>
        <th>Optiuni</th>
    </tr>
    </thead>
    <tbody>
    <% 
    int count = 0;
    for( CollegeBean cb : College.fetchAll(ub.getUniversityId()) ) { %>
    <tr <% if( count++ % 2 == 0) {%>class="odd"<%}else{%>class="even"<%}%>>
        <td><%=cb.getCollegeId()%></td>
        <td>
            <a href="list-place.jsp?cid=<%=cb.getCollegeId()%>">
            <%=cb.getName()%></a>
        </td>
        <td><%=cb.getAddress()%></td>
        <td><% if(cb.isAvailable()) {%>Activa<%}else{%>Inactiv<%}%></td>
        <td>
            <a href="remove-college.jsp?cid=<%=cb.getCollegeId()%>&amp;uid=<%=cb.getUniversityId()%>"
            onclick="return confirm('Esti sigur?')">sterge</a> - 
            <a href="switch-college.jsp?cid=<%=cb.getCollegeId()%>&amp;uid=<%=cb.getUniversityId()%>">
                <% if(cb.isAvailable()) {%>
                    dezactiveaza
                <% } else { %>
                    activeaza
                <% } %>
            </a>
        </td>
    </tr>
    <% } %>
    </tbody>
</table>

<%@include file="_footer.jspf" %>